package at.jaki.ubb.crawling.model;

import java.util.Date;

public class RawData<E> {

	/**
	 * maximum length of data shown by the toString method
	 */
	private static final int MAX_TO_STRING_LENGHT = 20;

	private String id;
	private E data;
	private Date createdOn;
	private String type;

	public RawData(String id, E data, Date createdOn, String type) {
		super();
		this.id = id;
		this.data = data;
		this.createdOn = createdOn;
		this.type = type;
	}

	public final String getId() {
		return id;
	}

	public final E getData() {
		return data;
	}

	public final Date getCreatedOn() {
		return createdOn;
	}

	public final String getType() {
		return type;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append('[');
		sb.append(id);
		sb.append("] - ");
		sb.append(type);
		sb.append(" - ");
		sb.append(createdOn);
		sb.append(" - ");
		if (data != null) {
			sb.append(getData().toString().substring(0, Math.min(getData().toString().length(), MAX_TO_STRING_LENGHT)));
		} else{
			sb.append("NULL");
		}
		return sb.toString();
	}

}
